package com.nchu.student_score.controller;

import com.github.pagehelper.PageInfo;
import com.nchu.student_score.model.Admin;
import com.nchu.student_score.service.AdminService;
import com.nchu.student_score.vo.ResultVo;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin")
public class AdminController {
    @Resource
    AdminService adminService;

    @RequestMapping("addOneAdmin/{superAdminKey}")
    public ResultVo<Admin> addOneAdmin(@RequestBody Admin input,@PathVariable String superAdminKey){
        return adminService.addOneAdmin(input, superAdminKey);
    }

    @RequestMapping("adminPwdInit/{superAdminKey}")
    public ResultVo<Admin> adminPwdInit(@RequestBody Admin input,@PathVariable String superAdminKey){
        return adminService.adminPwdInit(input, superAdminKey);
    }

    @RequestMapping("getAdminList/{currPage}")
    public PageInfo<Admin> getAdminList(@RequestBody Admin admin, @PathVariable Integer currPage){
        return adminService.getAdminList(admin,currPage);
    }

    @RequestMapping("updateOneAdmin/{superAdminKey}")
    public ResultVo<Admin> updateOneAdmin(@RequestBody Admin input,@PathVariable String superAdminKey){
        return adminService.updateOneAdmin(input,superAdminKey);
    }
}
